package com.yvan.elasticjob;

import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.google.common.base.Objects;

import com.dangdang.ddframe.job.lite.api.JobScheduler;


/**
 * Created by xiaoEight on 2018/6/20.
 */
public class BeanJobSchedulerHolder {

    private final SimpleJob bean;
    private final JobScheduler jobScheduler;

    public BeanJobSchedulerHolder(SimpleJob bean, JobScheduler jobScheduler) {
        this.bean = bean;
        this.jobScheduler = jobScheduler;
    }

    public Object getBean() {
        return this.bean;
    }

    public JobScheduler getJobScheduler() {
        return this.jobScheduler;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(this.bean, this.jobScheduler);
    }

    @Override
    public boolean equals(Object object) {
        if (object instanceof BeanJobSchedulerHolder) {
            BeanJobSchedulerHolder that = (BeanJobSchedulerHolder) object;
            return Objects.equal(this.bean, that.bean) && Objects.equal(this.jobScheduler, that.jobScheduler);
        }
        return false;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(this)
                .add("bean", this.bean)
                .add("jobScheduler", this.jobScheduler)
                .toString();
    }
}
